package com.changan.controller;


import com.changan.entity.Menu;
import com.changan.response.Result;
import com.changan.service.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author xsy
 * @since 2021-08-26
 */
@CrossOrigin
@Api(value = "111",tags = "菜单权限管理")
@RestController
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    private MenuService menuService;

    /*
    加载菜单树
     */
    @ApiOperation(value = "加载菜单树",notes = "获取所有菜单")
    @GetMapping("/getTree")
    public Result tree(){
        List<Menu> menTree=menuService.buildMenuTree();
        menTree.forEach(System.out::println);
        return Result.ok().data("menTree",menTree);
    }
}

